﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Entity;
using System.Data;
using System.Configuration;

namespace DataAccess
{
    /// <summary>
    /// 用户关系实体类。
    /// </summary>
    public class RelationshipDAL
    {
        private OleDbHelper helper;

        public RelationshipDAL()
        {
            helper = new OleDbHelper();
            helper.ConnectionString = ConfigurationManager.ConnectionStrings["jianbo"].ConnectionString;
        }

        /// <summary>
        /// 添加一个用户关系。
        /// </summary>
        /// <param name="relationship"></param>
        /// <returns>受影响的行数</returns>
        public int AddRelationship(Relationship relationship)
        {
            //准备SQL语句。
            string sql_text = "INSERT INTO jb_relationship(relationship_id, mineuser_id, yoursuser_id) VALUES(@rid, @mid, @yid);";
            //执行并返回受影响的行数。
            return helper.ExecuteNonQuery(sql_text, relationship.Id, relationship.MineUserId, relationship.YoursUserId);
        }

        public int DeleteRelationship(Guid id)
        {
            //准备SQL语句。
            string sql_text = "DELETE FROM jb_relationship WHERE relationship_id = @id;";
            //执行并返回受影响的行数。
            return helper.ExecuteNonQuery(sql_text, id);
        }

    }
}
